package com.tyk.bookstore.front.order.repository;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.tyk.bookstore.front.common.core.model.enume.PaymentWay;
import com.tyk.bookstore.front.common.dal.mapper.IMapper;
import com.tyk.bookstore.front.order.dto.Order4StockDto;
import com.tyk.bookstore.front.order.model.dto.*;
import com.tyk.bookstore.front.order.model.emume.OrderState;
import com.tyk.bookstore.front.order.model.entity.OrderDo;
import com.tyk.bookstore.front.order.vo.OrderSplitDto;
import com.tyk.bookstore.front.order.vo.OrderSplitSubDto;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Set;

/**
 * @author tyk
 * @description 订单管理
 */
@Mapper
public interface OrderRepository extends IMapper<OrderDo> {
    BigDecimal selectOrderAmountById(@Param("id") Long id, @Param("orderNo") String orderNo, @Param("memberId") Long memberId);

    List<Long> selectIdListParentId(@Param("parentId") Long parentId);


    void updateBatchByIdList(@Param("idList") List<Long> idList, @Param("state") OrderState state, @Param("paymentWay") PaymentWay paymentWay, @Param("paymentTime") LocalDateTime paymentTime);

    LocalDateTime selectCreateTimeById(@Param("id") Long id);

    /**
     * 获取符合条件的订单的简略信息
     */
    List<OrderBriefDto> selectOrderBriefDtoListByCondition(@Param("ew") LambdaQueryWrapper<OrderDo> ew);

    /**
     * 获取符合条件的订单的简略信息
     */
    List<OrderBriefDto> selectOrderBriefDtoListByIdSet(@Param("idSet") Set<Long> idSet);

    /**
     * 获取符合条件的订单的详细信息
     */
    List<OrderExplicitDto> selectOrderExplicitDtoListByIdSet(@Param("idSet") Set<Long> idSet);

    void deleteByIdAndMemberId(@Param("id") Long id, @Param("memberId") Long memberId);

    void deleteBatchByIdList(@Param("idList") List<Long> idList, @Param("memberId") Long memberId);

    /**
     * 查询待支付订单数据
     */
    OrderSubmitDto selectOrderSubmitDto(@Param("id") Long id, @Param("memberId") Long memberId);

    OrderState selectOrderStateById(@Param("id") Long id, @Param("memberId") Long memberId);

    Long existById(@Param("id") Long id, @Param("memberId") Long memberId);

    Long selectWarehouseId(@Param("orderId") Long orderId);

    /**
     * 查询订单各明细数量信息
     */
    List<Order4StockDto> selectOrder4StockDtoLitByIdSet(@Param("idSet") Set<Long> idSet);

    OrderCancelConfirmDto selectOrderCancelConfirmDtoById(@Param("id") Long id, @Param("memberId") Long memberId);

    /***
     * 查询被拆分的订单的信息
     */
    OrderSplitDto selectSplitOrderDtoById(@Param("id") Long id);

    /**
     * 查询被拆分的订单的信子订单信息
     */
    List<OrderSplitSubDto> selectSplitOrderSubDtoListByParentId(@Param("parentId") Long parentId);

    /**
     * 查询订单信息
     */
    Order4PaymentDto selectOrder4PaymentDtoByIdAndMemberId(@Param("id") Long id, @Param("memberId") Long memberId);

    /**
     * 查询订单信息
     */
    Order4PaymentDto selectOrder4PaymentDtoById(@Param("id") Long id);
}
